﻿#pragma once
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<locale.h>
#include<stdbool.h>
#include<assert.h>
#include<time.h>
#define Wall L'□'
#define Body L'●'
#define FOOD L'★'
#define Key_state(KEY) ((GetAsyncKeyState(KEY)&(0x1))?1:0)
enum state
{
	ok = 1,
	by_wall,
	by_self,
	by_end
};
enum direction
{
	up=1,
	down,
	left,
	right
};
typedef struct SnakeNode
{
	int x;
	int y;
	struct SnakeNode*next;
}SnakeNode,*pSnakeNode;
typedef struct Food
{
	int x;
	int y;
}Food,*pFood;
typedef struct Snake
{
	pSnakeNode _snake;
	pFood _food;
	int _score;
	enum direction dir;
	enum state sta;
	int _weight;
	int _sleeptime;
}Snake,*pSnake;
void gamestart(pSnake snake);
void setpos(int x, int y);
void welcome();
void creatmap();
void creatfood(pSnake snake);
void initsnake(pSnake snake);
void creatsnake(pSnake snake);
void gameinfo(pSnake snake);
void gamerun(pSnake snake);
void pause();
void snakemove(pSnake snake);
void kill_self(pSnake snake);
void gameend(pSnake snake);
